package com.hdax.dm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdax.dm.entity.item.ItemComment;
import com.hdax.dm.mapper.item.ItemCommentMapper;
import com.hdax.dm.service.ItemCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemCommentServiceImpl extends ServiceImpl<ItemCommentMapper, ItemComment> implements ItemCommentService {

    @Override
    public List<ItemComment> getComments(Long id) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("itemId",id);
        queryWrapper.last("limit 10");
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public boolean addComments(ItemComment itemComme) {
        return baseMapper.insert(itemComme)>0;
    }

}
